<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../dist/css/login.css">
</head>

<body>
  <header>
    <div id="box">
      <span> <img src="../assets/images/HUAWEI.svg" class="adHeadPic" style="height: 24px;width:108px;margin-top: 0px;">
      </span>
      <span><a href="index.html">华为商城</a> </span>
    </div>
  </header>
  <section>
    <h2>华为账号登录</h2>
    <div id="form">
      <form id="login">

        <p class="userin">

          <label>请输入用户名：</label>
          <input type="text" name="username" placeholder="手机号/邮件地址/账户名">

        </p>
        <p class="passin">
          <label>请输入密码：</label>
          <img src="../assets/images/close.png" alt="" id="eye">
          <input type="password" name="password" id="passhaid" placeholder="密码">
        </p>
        <p class="mian">
          <i>
            <input type="checkbox" id="check">
            <label for="check">记住我</label>


          </i>

          <i><a href="reg.html" id="toreg">点击注册</a></i>
        </p>

        <div>
          <button id='btn'>进入系统</button>
        </div>
      </form>
    </div>

  </section>



  <script src="../dist/js/jquery-3.5.1.min.js"></script>
  <!-- 引入jquery第3方插件 -->
  <script src="../dist/js/layer.js"></script>
  <!-- <script src="js/login.js"></script> -->
  <script>
    $('#btn').click(function () {


      $.post('../login.php', $('#login').serialize(), null, 'json').then(res => {
        // alert(res.msg)
        layer.alert(res.msg, {}, function () {
          layer.closeAll()
          console.log('aaaa')


          if (res.type == "success") {

            self.location = '../0422/index.html';
          }

        })
      })


      return false  //取消默认设置
    })


    var eye = document.getElementById('eye');
    var pwd = document.getElementById('passhaid');
    // 2. 注册事件 处理程序
    var flag = 0;
    eye.onclick = function () {
      if (flag == 0) {
        pwd.type = 'text';
        eye.src = '../assets/images/open.png';
        flag = 1; // 赋值操作
      } else {
        pwd.type = 'password';
        eye.src = '../assets/images/close.png';
        flag = 0;
      }

    }


    







  </script>
</body>

</html>